<?php

namespace App\Http\Requests\Admin;

use App\Http\Requests\Request;

class AdminInsertRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        //验证开启
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            //
        'aname' => 'required|unique:admin|regex:/^\w{5,12}$/',
        'apassword'=>'required',
        'arepassword'=>'required|same:apassword'
        ];
    }

    public function messages()
    {
         return [
            'aname.required'=>'用户名必填',
            'aname.unique'=>'用户名存在',
            'aname.regex'=>'用户名格式错误',
            'apassword.required'=>'密码必填',
            'arepassword.required'=>'确认密码必填',
            'arepassword.same'=>'两次密码不一致'
            ];
    }
}
